﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Resources;

namespace WLS
{
    public partial class title : Form
    {
        Information fr1;
        Silverlight fr2;
        Youtube_wf fr3;
        data video;
        byte vyber;
        bool checkbox;
        all_setting p;

        public title(data video_, ref all_setting _jazyk)
        {
            InitializeComponent();
            video = video_;
            p = _jazyk;
            p.JazykZmenen += new all_setting.ZmenaJazyku(jazyk_JazykZmenen);
            jazyk_JazykZmenen(p.jazyk);
        }

        /// <summary>
        /// Změní jazyk
        /// </summary>
        /// <param name="jazyk"></param>
        void jazyk_JazykZmenen(string jazyk)
        {
            CultureInfo cultura = CultureInfo.CreateSpecificCulture(jazyk);
            ResourceManager manager = new ResourceManager("WLS.Res", typeof(title).Assembly);
            label3.Text = manager.GetString("uploadto", cultura);
            menuItem4.Text = manager.GetString("delete", cultura);
            menuItem2.Text = manager.GetString("add", cultura);
            menuItem3.Text = manager.GetString("infoo", cultura);
            menuItem1.Text = manager.GetString("possibilities", cultura);
            this.Text = manager.GetString("title", cultura);
            logadd = manager.GetString("logadd", cultura);
            logaddelete = manager.GetString("logaddelete", cultura);
            incorect = manager.GetString("incorect", cultura);
            checkBox3.Text = manager.GetString("Agree", cultura);
            linkLabel1.Text = manager.GetString("share", cultura);
        }

        string logaddelete;
        string logadd;
        string incorect;



        private void title_Load(object sender, EventArgs e)
        {
            if (this.Tag != null) video = (data)this.Tag;
            vyber = video.uplaod;
            checkbox = false;
            if ((vyber & 0) == 0)
            {
                checkBox1.Checked = false;
                checkBox2.Checked = false;
            }
            if ((vyber & 1) == 1)
            {
                checkBox1.Checked = true;
                checkBox2.Checked = false;
            }
            if ((vyber & 2) == 2)
            {
                checkBox1.Checked = false;
                checkBox2.Checked = true;
            }
            if ((vyber & 3) == 3)
            {
                checkBox1.Checked = true;
                checkBox2.Checked = true;
            }

            checkbox = true;
            checkBox3.Checked = video.law;
            menuItem2.Enabled = video.law;
        }

        private void checkBox1_CheckStateChanged(object sender, EventArgs e)
        {
            if (checkbox == true)
            {
                if (checkBox1.Checked == true)
                {
                    if (fr2 == null) fr2 = new Silverlight(video, ref p);
                    else fr2.Tag = (data)video;
                    fr2.ShowDialog();
                    if (((silverlights)((data)video).silver).filesetname == "")
                        checkBox1.Checked = false;
                }
            }
        }

        private void checkBox2_CheckStateChanged(object sender, EventArgs e)
        {

            if (checkbox == true)
            {
                if (checkBox2.Checked == true)
                {
                    if (fr3 == null) fr3 = new Youtube_wf(video, ref p);
                    else fr3.Tag = (data)video;
                    fr3.ShowDialog();
                    if (((youtube)((data)video).yout).filesetname == "")
                        checkBox2.Checked = false;
                }
            }
        }

        private void checkBox3_CheckStateChanged(object sender, EventArgs e)
        {
            if (checkBox3.Checked == true)
                menuItem2.Enabled = true;
            else
                menuItem2.Enabled = false;

        }

        private void menuItem4_Click(object sender, EventArgs e)
        {
            video.path = "";
            p.log = logaddelete + Environment.NewLine + p.log;
            this.Close();
        }

        private void menuItem3_Click(object sender, EventArgs e)
        {
            if (fr1 == null) fr1 = new Information(video, ref p);
            else fr1.Tag = video;
            fr1.ShowDialog();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            vyber = 0;
            if (checkBox1.Checked == true)
                vyber += 1;
            if (checkBox2.Checked == true)
                vyber += 2;
            video.uplaod = vyber;
            video.law = checkBox3.Checked;
            p.log = logadd + Environment.NewLine + p.log;
            checkBox1.Checked = false;
            checkBox2.Checked = false;
            this.Close();
        }

        private void linkLabel1_Click(object sender, EventArgs e)
        {
            //System.Diagnostics.Process.Start("http://www.youtube.com/my_account?hl=en&gl=US&warned=True&client=mv-google&nomobile=1", ""); 
            //System.Diagnostics.Process.Start("http://www.youtube.com/account#sharing/activity", "");
        }

    }
}